<?php
class Default_Models_Mongo_UserModel extends Shanty_Mongo_Document{
	protected static $_db = "call_link";
	protected static $_collection = "user";//tên document
	
	public function getAllUserAdmin(){
		$user_list = $this->all()->sort(array('_id'	=> -1));
		return $user_list;
	}
	public function getPermissionManagerList(){
		$user_list = $this->all(array("permission_manager"	=> 1))->sort(array('_id'	=> -1));
		return $user_list;
	}
	public function getNotPermissionManagerList(){
		$user_list = $this->all(array("permission_manager"	=> array("\$ne"	=> 1)))->sort(array('_id'	=> -1));
		return $user_list;
	}
	public function getUserInfo($id){
		if (!$id){
			return false;
		}
		$user_info = $this->find($id);
		return $user_info;
	}
	public function getUserInfoByUsername($username){
		if (!$username){
			return false;
		}
		$user_info = $this->fetchOne(array("username"	=> $username));
		return $user_info;
	}
}